package com.jinzhi.jinzhidata.service.impl;

import com.jinzhi.jinzhidata.dataobject.Order;
import com.jinzhi.jinzhidata.repository.OrderRepository;
import com.jinzhi.jinzhidata.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description
 * @date 2020-01-03 17:25
 **/
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    OrderRepository orderRepository;

    @Override
    public Order selectOrderByUserAndGoods(String userId, String resoureId) {
        return orderRepository.findByOrderUserIdAndOrderGoodsId(userId, resoureId);
    }

    @Override
    public Order saveOrder(Order order) {
        return orderRepository.save(order);
    }

    @Override
    public Order selectOrderByOrderId(String orderId) {
        return orderRepository.findById(orderId).orElse(null);
    }

    @Override
    public List<String> selectGoodsIdListByUser(String userId) {
        return orderRepository.selectGoodsIdListByUser(userId);
    }
}
